import React from 'react';
import CommonPage from '@/components/page/CommonPage';
import { format } from '@/utils/datetime';

const daoName = 'UserLog';
const columns: API.Column[] = [
  {
    title: '员工编号',
    width: 140,
    sorter: true,
    key: 'SysUserID',
    dataIndex: 'SysUserID',
    dispaly: true,
    filter: true,
  },
  {
    title: '员工姓名',
    width: 150,
    sorter: true,
    key: 'SysUserName',
    dataIndex: 'SysUserName',
    dispaly: true,
    filter: true,
  },
  {
    title: '所属部门',
    width: 170,
    sorter: true,
    key: 'OrganName',
    dataIndex: 'OrganName',
    dispaly: true,
    filter: true,
  },
  {
    title: '操作菜单',
    width: 280,
    sorter: true,
    key: 'PermissionName',
    dataIndex: 'PermissionName',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '操作内容',
    width: 250,
    sorter: true,
    key: 'UseContent',
    dataIndex: 'UseContent',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '用户IP',
    width: 120,
    sorter: true,
    key: 'UserIP',
    dataIndex: 'UserIP',
    dispaly: true,
    //filter: true,
    export: true,
  },
  {
    title: '操作时间',
    width: 150,
    sorter: true,
    key: 'UseTime',
    dataIndex: 'UseTime',
    render: (data) => format(data, 'yyyy-MM-dd hh:mm:ss'),
    dispaly: true,
    filter: true,
    export: true,
  },
];
const controls: API.Control[] = [
  {
    name: 'SysUserID',
    label: '员工编号',
    type: 'text',
    grid: 12 / 24,
    dataType: 'string',
  },
  {
    name: 'SysUserName',
    label: '员工姓名',
    type: 'text',
    grid: 12 / 24,
    dataType: 'string',
  },
  {
    name: 'OrganName',
    label: '所属部门',
    type: 'text',
    grid: 12 / 24,
    dataType: 'string',
  },
  {
    name: 'PermissionName',
    label: '操作菜单',
    type: 'text',
    grid: 12 / 24,
    dataType: 'string',
  },
  {
    name: 'UseContent',
    type: 'text',
    dataType: 'string',
    label: '操作内容',
    grid: 12 / 24,
  },
  {
    name: 'UserIP',
    type: 'text',
    dataType: 'string',
    label: '用户IP',
    grid: 12 / 24,
  },
  {
    name: 'UseTime',
    type: 'date',
    dataType: 'date',
    label: '操作时间',
    grid: 12 / 24,
  },
];

const UserLogForm: React.FC = () => {
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      initSorter={{
        FieldName: 'UseTime',
        Direction: 'DESC',
      }}
      title="用户操作日志"
    />
  );
};
export default UserLogForm;
